<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>档案管理</title>
    <meta name="description" content="">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <link rel="stylesheet" href="/resources/css/employee.type.css">
    <link rel="stylesheet" href="/resources/css/amazeui.videojs.css">
    <script src="/resources/js/jquery.min.js"></script>
    <script src="/resources/js/jquery.form.js"></script>
    <script src="/resources/jsutlis/fileutli.js"></script>
    <script src="/resources/js/video.js"></script>
    <script src="/resources/jsutlis/DateFormat.js"></script>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
    #secondTable tr td{
        text-align: left;
        border: 0px;
    }
</style>
<body data-type="widgets">
<script src="/resources/js/theme.js"></script>
<div class="am-g tpl-g">
    <%--头部开始--%>
    <%@include file="header.jsp" %>
    <%--头部结束--%>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">

        <div class="container-fluid am-cf">
            <div class="row">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                        <div class="page-header-heading"><span
                                class="am-icon-file-excel-o page-header-heading-icon"></span> 阶段性档案查看
                            <small>Baby Records</small>
                        </div>
                        <p class="page-header-description">档案查看，管理、附件添加</p>
                    </div>
                </div>
                <div class="am-u-lg-3 tpl-index-settings-button">
                    <%--<button type="button" class="page-header-button"--%>
                </div>
            </div>

        </div>

        <div class="row-content am-cf">
            <div class="row widget  am-cf" id="content">
                <!--<div class="am-u-md-1  am-u-lg-2"></div>-->
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <%--新的菜单模式--%>

                    <table width="100%" class="am-table am-table-bordered am-table-compact tpl-table-black "
                           id="example-r">
                        <caption>${baby.babyName}档案列表</caption>
                        <tr>
                            <th>序号</th>
                            <th>创建时间</th>
                            <th>创建人</th>

                            <th>备注</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        <c:forEach items="${pageInfo.list}" var="p" varStatus="i">
                            <tr>
                                <td>${i.index+1}</td>
                                <td><fmt:formatDate pattern="yyyy-MM-dd" value="${p.createTime}"/></td>
                                <td>${p.emname}</td>

                                <td>${p.remarks}</td>
                                <td>
                                    <c:if test="${p.status==1}">正常</c:if>
                                    <c:if test="${p.status==0}">异常</c:if>
                                </td>
                                <td>
                                    <a href="javascript:seeDetails(${p.id})"><i class="am-icon-eye"></i>点击查看详情</a>&nbsp;&nbsp;&nbsp;
                                    <a href="javascript:uploadVideo('${p.id}')"><i class="am-icon-film"></i>上传视频附件</a>&nbsp;&nbsp;&nbsp;
                                    <a href="javascript:uploadPhoto('${p.id}')" id="picrture${p.id}" data-path="${p.picrture}" ><i class="am-icon-file-photo-o"></i>上传图片附件</a>&nbsp;&nbsp;&nbsp;
                                        <%--   <c:if test="${p.status==1}"> <a href="javascript:setProblemsstatus('${p.id}',0)">点击禁用</a></c:if>

                                           <c:if test="${p.status==0}"> <a href="javascript:setProblemsstatus('${p.id}',1)"><i class="am-icon-pencil"></i>点击启用</a></c:if>--%>
                                </td>
                            </tr>
                        </c:forEach>
                    </table>

                    <div class="am-u-lg-12 am-cf paging">

                        <!-- 分页文字信息，其中分页信息都封装在pageInfo中 -->
                        <div class="col-md-6">
                            当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                        </div>
                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
                                <!-- 首页 -->
                                <li><a href="/rf/getbrfl?babyId=${baby.babyId}&pn=1">首页</a></li>
                                <!-- 上一页 -->
                                <c:if test="${pageInfo.hasPreviousPage }">
                                    <li>
                                        <a href="/rf/getbrfl?babyId=${baby.babyId}&pn=${pageInfo.pageNum-1 }"
                                           aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                </c:if>
                                <!-- 循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接 -->
                                <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                                    <c:if test="${page_Num == pageInfo.pageNum }">
                                        <li class="am-active"><a
                                                href="/pro/getlist?babyId=${baby.babyId}&pn=${page_Num }">${page_Num }</a>
                                        </li>
                                    </c:if>
                                    <c:if test="${page_Num != pageInfo.pageNum }">
                                        <li><a href="/rf/getbrfl?babyId=${baby.babyId}&pn=${page_Num }">${page_Num }</a>
                                        </li>
                                    </c:if>
                                </c:forEach>
                                <!-- 下一页 -->
                                <c:if test="${pageInfo.hasNextPage }">
                                    <li>
                                        <a href="/rf/getbrfl?babyId=${baby.babyId}&pn=${pageInfo.pageNum+1 }"
                                           aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                </c:if>
                                <!-- 末页 -->
                                <li><a href="/rf/getbrfl?babyId=${baby.babyId}&pn=${pageInfo.pages }">末页</a></li>
                            </ul>
                        </div>
                    </div>
                    <form id="updatproform" action="/pro/setStatus" method="post">
                        <table width="100%" class="am-table am-table-bordered am-table-compact tpl-table-black"
                               id="secondTable" style="display: none">
                            <caption>xxx宝宝的详细档案</caption>
                            <tr><td>档案采集时间：2018-25-24</td><td>相关说明：一般是备注或者其他的吧</td></tr>
                            <tr><td colspan="2">下面是详细信息及附件</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢是不是喜欢吃肉或者喜欢做其他的是不是喜欢吃肉或者喜欢做其他的是不是喜欢吃肉或者喜欢做其他的是不是喜欢吃肉或者喜欢做其他的是不是喜欢吃肉或者喜欢做其他的做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td>问题：是不是喜欢吃肉或者喜欢做其他的</td><td>很喜欢吃肉或者吃蔬菜</td></tr>
                            <tr><td colspan="2">附件：<br><img style="min-height: 100px;max-height: 400px" src="\files\tmpFiles\20188817224999.jpg"></td></tr>
                            <tr><td colspan="2">视频：<br>
                                <video id="detilsrecordVideo" class="video-js vjs-amazeui" controls preload="none"
                                                               width="640" height="264"
                                                               poster="/resources/img/logo.png"
                                                               data-setup="{}">
                                <source src="" type='video/mp4'/>
                                <track kind="captions" src="" srclang="en" label="English" /><!-- Tracks need an ending tag thanks to IE9 -->
                                <track kind="subtitles" src="" srclang="en" label="English"/><!-- Tracks need an ending tag thanks to IE9 -->
                                <p class="vjs-no-js">
                                    请允许你的浏览器使用JavaScript,你也可以更新你的浏览器或者换一个支持html5的浏览器</p>
                            </video></td></tr>
                        </table>
                    </form>

                </div>
                <!--分页插件Start-->
                <div class="am-u-lg-12 am-cf paging">

                </div>
            </div>
        </div>
    </div>

    <!-- 图片模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="RecordModel" >
        <div class="am-modal-dialog">
            <div class="am-modal-bd" style="padding: 1px;">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf" style="margin: 0;">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><h2>档案图片上上传</h2></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript: void(0)" class="am-close am-close-spin clearForm">&times;</a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-border-form tpl-form-border-br" id="productForm">

                                    <!-- 主键 -->
                                    <div class="am-form-group am-hide">
                                        <label class="am-u-sm-3 am-form-label"></label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="productId"
                                                   class="am-form-field tpl-form-no-bg productId"/>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 商品图片 -->
                                    <div class="am-form-group">
                                        <label class="am-form-label">宝宝档案图片</label>

                                        <div class="tpl-form-file-img" style="width:660px;height:360px;margin:auto;">
                                            <div id="myCarousel" class="carousel slide" style="width:100%;height:100%;margin:auto;">
                                                <!-- 轮播（Carousel）项目 -->
                                                <div class="carousel-inner">
                                                    <!-- <div class="item active">
                                                        <img class="firstimg"  src="" style="width:280px;height:250px;margin:auto 10px;" alt="照片">
                                                    </div> -->
                                                </div>
                                                <!-- 轮播（Carousel）导航 -->
                                                <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                                                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                                                    <span class="sr-only">Previous</span>
                                                </a>
                                                <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                                                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                                                    <span class="sr-only">Next</span>
                                                </a>
                                            </div>
                                            <input type="hidden" id="recordImage">
                                        </div>
                                        <br>
                                        <div id="upBtndiv">
                                            <div class="am-form-group am-form-file">
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                    <i class="am-icon-cloud-upload"></i> 上传图片
                                                </button>

                                                <input type="file" class="addBabyPhoto" multiple>
                                                <%-- 用于保存存入的地址 --%>
                                                <input type="hidden" name="id" class="am-hide proPhoto" id="rfid">
                                                <input type="hidden" name="picrture" class="am-hide proPhoto"
                                                       id="strPhoto">
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 按钮 -->
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 整个表单结束 -->
            </div>
        </div>
    </div>
    <!-- 图片模态框结束 -->
    <!-- 视频模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="RecordVideoModel">
        <div class="am-modal-dialog">
            <div class="am-modal-bd" style="padding: 1px;">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf" style="margin: 0;">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><h2>档案视频上传</h2></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript: void(0)" class="am-close am-close-spin clearForm"><%--&times;--%></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-border-form tpl-form-border-br" id="videoForm">

                                    <!-- 主键 -->
                                    <div class="am-form-group am-hide">
                                        <label class="am-u-sm-3 am-form-label"></label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="productId"
                                                   class="am-form-field tpl-form-no-bg productId"/>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 商品图片 -->
                                    <div class="am-form-group">
                                        <label class="am-form-label">宝宝附件视频</label>

                                        <div class="tpl-form-file-img">
                                            <div style="display: inline">
                                                <video id="recordVideo" class="video-js vjs-amazeui" controls preload="none"
                                                       width="640" height="264"
                                                       poster="/resources/img/logo.png"
                                                       data-setup="{}">
                                                    <source src="" type='video/mp4'/>
                                                    <source src="" type='video/mp4' />
                                                    <!--<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
                                                    <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />-->
                                                    <track kind="captions" src="" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
                                                    <track kind="subtitles" src="" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
                                                    <p class="vjs-no-js">
                                                        请允许你的浏览器使用JavaScript,你也可以更新你的浏览器或者换一个支持html5的浏览器</p>
                                                </video>
                                            </div>
                                            <%-- <img class="image" id="" style="width: 410px; height: 250px;">--%>
                                        </div>
                                        <br>
                                        <div id="upVideoBtndiv">
                                            <div class="am-form-group am-form-file">
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                    <i class="am-icon-cloud-upload"></i> 上传视频
                                                </button>

                                                <input type="file" class="addBabyVideo">
                                                <%-- 用于保存存入的地址 --%>
                                                <input type="hidden" name="id" class="am-hide proPhoto" id="videorfid">
                                                <input type="hidden" name="videos" class="am-hide proPhoto"
                                                       id="strVideo">
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 按钮 -->
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 整个表单结束 -->
            </div>
        </div>
    </div>

    <!-- 视频模态框结束 -->

    <!-- 查看图片模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="showPictureModel">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div class="am-modal-bd">
                <div class="tpl-form-file-img">
                    <img alt="未找到图片" id="imagePhoto" width="580px" height="440px">
                </div>
            </div>
        </div>
    </div>
    <!-- 查看图片模态框结束 -->


    <script src="/resources/js/amazeui.min.js"></script>
    <script src="/resources/js/amazeui.datatables.min.js"></script>
    <script src="/resources/js/dataTables.responsive.min.js"></script>
    <script src="/resources/js/app.js"></script>
    <script>
        function addProblem() {
            $('#proform').ajaxSubmit(function (res) {
                if (res.result) {
                    var data = res.data;
                    var tableStr = '  <tr><td>问题</td><td colspan="4"><input type="text" name="content" value="' + data.content + '" style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td></tr>\n' +
                        '<tr><td rowspan="2">选项</td><td><input type="text" name="optiona" value="' + data.optiona + '"  style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td> <td><input type="text"  value="' + data.optionb + '" style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td> <td><input type="text" name="optionc"  value="' + data.optionc + '"  style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td> <td><input type="text" name="optiond" p value="' + data.optiond + '" style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td> </tr>\n' +
                        '<tr><td><input type="text" name="optione" value="' + data.optione + '" style="width: 100%;min-height: 40px;margin: 0;padding:0"></td> <td><input type="text" name="optionf" value="' + data.optionf + '" style="width: 100%;min-height: 40px;margin: 0;padding:0"></td> <td><input type="text" name="optiong" value="' + data.optiong + '"   style="width: 100%;min-height: 40px;margin: 0;padding:0"></td><td><input type="text" name="optionh" value="' + data.optionh + '"  style="width: 100%;min-height: 40px;margin: 0;padding:0" ></td></tr>';
                    $('#secondTable').append(tableStr);
                    $('#secondTable').show();
                    $('#proform').reset();
                } else {
                    alert("数据失败，刷新页面重试");
                }
                return false;
            });
        }

        function setProblemsstatus(id, status) {
            var url = '/pro/setStatus?pid=' + id + '&status=' + status;
            $.ajax({
                url: url,
                type: 'get',
                cache: false,
                processData: false,
                contentType: false
            }).done(function (res) {
                console.log(res);
                if (res.result) {
                    window.location.reload();
                } else {
                    alert("数据失败，刷新页面重试");
                }
            }).fail(function () {
                alert("网络错误,请刷新重试");
            });
        }

        function seeDetails(id) {
            var url = "/rf/getrfbd?rfid=" + id;
            $('#secondTable').empty();
            console.log("开始显示");
            console.log(id);
            $.ajax({
                url: url,
                type: 'get',
                cache: false,
                processData: false,
                contentType: false
            }).done(function (res) {
                console.log(res);
                if (!res.result) {
                    var data = res.data;
                    var babyinfo =data.baby;
                    var detils =data.detils;
                    var record =data.record;
                    var date =formatDate(record.createTime);
                    var birth =formatDate(babyinfo.babybirthday,'YY年MM月DD日');
                    var remark = record.remarks=='' ? "无" :record.remarks;
                    console.log(remark);
                    var tableStr = '<caption>'+babyinfo.babyName+'详细档案</caption><tr><td>宝宝生日'+birth+'</td><td>纸质档案编号：'+babyinfo.fileNo+'</td></tr><tr><td>档案采集时间'+date+'</td><td>相关说明：'+remark+'</td></tr>';
                    for (var i=0;i<detils.length;i++){
                        var dtmp =detils[i];
                        tableStr+=' <tr><td>'+dtmp.problemContent+'</td><td>'+dtmp.answers+'</td></tr>';
                    }
                    if (record.picrture!=null && record.picrture!= undefined && record.picrture!=''){
                        var result =record.picrture.split(",");
                        var div ='';
                        for (var i=0 ; i<result.length;i++){
                           div +='<img style="min-height: 100px;max-height: 400px" src="'+result[i]+'">';
                        }

                        tableStr+= '<tr><td colspan="2">附件：<br>'+div+'</td></tr>';
                        /*tableStr+= '<tr><td colspan="2">附件：<br><img style="min-height: 100px;max-height: 400px" src="'+record.picrture+'"></td></tr>';*/
                    }
                    if (record.videos!=null && record.videos!= undefined && record.videos!=''){
                        tableStr+=' <tr><td colspan="2">视频：<br>\n' +
                            '                                <video id="detilsrecordVideo" class="video-js vjs-amazeui" controls preload="none"' +
                            '                                                               width="640" height="264"' +
                            '                                                               poster="/resources/img/logo.png"' +
                            '                                                               data-setup="{}">' +
                            '                                <source src="'+record.videos+'" type="video/mp4"/>' +
                            '                                <track kind="captions" src="" srclang="en" label="English" /><!-- Tracks need an ending tag thanks to IE9 -->\n' +
                            '                                <track kind="subtitles" src="" srclang="en" label="English"/><!-- Tracks need an ending tag thanks to IE9 -->\n' +
                            '                                <p class="vjs-no-js">\n' +
                            '                                    请允许你的浏览器使用JavaScript,你也可以更新你的浏览器或者换一个支持html5的浏览器</p>\n' +
                            '                            </video></td></tr>';
                        var player = videojs('#detilsrecordVideo');
                         player.ready(function () {
                            var obj  = this;
                            obj.src(record.videos);
                            obj.load();
                        });
                    }
                    $('#secondTable').append(tableStr);
                    $('#secondTable').show();
                } else {
                    alert("数据失败，刷新页面重试");
                }
            }).fail(function () {
                alert("网络错误,请刷新重试");
            });

        }

        function updatePro() {
            $('#updatproform').ajaxSubmit(function (res) {
                if (res.result) {
                    alert("更新成功");
                } else {
                    alert("更新失败");
                }
                return false;
            });
            window.location.reload();
        }

        function uploadPhoto(id) {
            $('#rfid').val(id);
            var imgpath=$('#picrture'+id).attr("data-path");

            console.log(imgpath);
            if (imgpath != null && imgpath != undefined && imgpath != '') {
                $("#recordImage").attr('value',imgpath);
                var result =imgpath.split(",");
                var div ='';
                for (var i=0;i<result.length;i++){
                    if (i ==0){
                        div = '<div class="item active"><img class="firstimg"  src="'+result[i] +'" style="width:660px;height:360px;margin:auto;" alt="照片"></div>';
                    } else {
                        div='<div class="item"><img src=' + result[i] + ' style="width:660px;height:360px;margin:auto;" alt="照片"></div>';
                    }
                    $(".carousel-inner").append(div);
                }
            }
            $('#RecordModel').modal({width: 720,height: 451});
        }

        // 上传头像，并回显
        $(".addBabyPhoto").bind('change', function () {
            var fordate = new FormData();  // 得到一个FormData对象：
            $(".carousel-inner").empty();
            $("#recordImage").attr({'value': ""});
            var fils = $(".addBabyPhoto").get(0).files.length;  // 得到file对象
            if (fils >3){
                alert("图片不能超过三张！");
                $(".addBabyPhoto").get(0).files==null;
                return;
            }
            fordate.append('pic', fils);  // 用append方法添加键值对
            var result = uploadfile('addBabyPhoto'); // 上传头像并返回结果
            if (result.code == 0) {
                $("#recordImage").attr({'value': result.data}); // 把图片回显
            /*    $(".carousel-inner").append(first_div);*/

                var div ='';
                for (var i=0;i<result.data.length;i++){
                    if (i ==0){
                       div = '<div class="item active"><img class="firstimg"  src="'+result.data[i] +'" style="width:660px;height:360px;margin:auto;" alt="照片"></div>';
                    } else {
                     div='<div class="item"><img src=' + result.data[i] + ' style="width:660px;height:360px;margin:auto;" alt="照片"></div>';
                    }
                    $(".carousel-inner").append(div);
                }
                $("#strPhoto").val(result.data); // 将路径存入不显示的文本框中
                var btn = '<button type="button" onclick="updatePic()" class="am-btn am-btn-success am-btn-sm"><i class="am-icon-cloud-upload" ></i> 更新数据到数据库</button>';
                $('#upBtndiv').append(btn);
            } else {
                alert("图片失败，请重新上传！");
            }
        });


        function updatePic() {
            var formdate = new FormData();
            var id = $('#rfid').val();
            var pic = $("#strPhoto").val();
            console.log(pic);
            if (id != null || id != undefined || id != '') {
                formdate.append("id", id);
                formdate.append("picrture", pic);
                console.log(formdate);
                var url = "/rf/updatebr";
                $.ajax({
                    url: url,
                    type: 'POST',
                    cache: false,
                    data: formdate,
                    processData: false,
                    contentType: false
                }).done(function (data) {
                    console.log(data);
                    if (data.success) {
                        $('#RecordModel').modal('close');
                        window.location.reload();
                    } else {
                        alert(data.msg);
                    }
                }).fail(function () {
                    alert("网络异常");
                });
            }
        }

        function uploadVideo(id,videopath) {
            $('#videorfid').val(id);
            if (videopath != null && videopath != undefined && videopath != '') {
                var player = videojs('#recordVideo');
                player.ready(function () {
                    var obj  = this;
                    obj.src(result.data);
                    obj.load();
                    // obj.play();
                });
            }
            $('#RecordVideoModel').modal({ width:"700",height:"264"});
        }

        // 上传视频回放
        $(".addBabyVideo").bind('change', function () {
            console.log("视频上传开始");
            var fordate = new FormData();  // 得到一个FormData对象：
            var fils = $(".addBabyVideo").get(0).files[0];  // 得到file对象
            fordate.append('pic', fils);  // 用append方法添加键值对
            var result = uploadfile('addBabyVideo'); // 上传头像并返回结果
            if (result.code == 0) {
                var player = videojs('#recordVideo');
                player.ready(function () {
                    var obj  = this;
                    obj.src(result.data);
                    obj.load();
                    // obj.play();
                });
                $("#recordVideo").attr({'src': result.data}); // 把视频回显
                $("#strVideo").val(result.data); // 将路径存入不显示的文本框中
                var btn = '<button type="button" onclick="updateVideo()" class="am-btn am-btn-success am-btn-sm"><i class="am-icon-cloud-upload" ></i> 更新数据到数据库</button>';
                $('#upVideoBtndiv').append(btn);
            } else {
                alert("图片失败，请重新上传！");
            }
        });

        function updateVideo() {
            var formdate = new FormData();
            var id = $('#videorfid').val();
            var videos = $("#strVideo").val();
            console.log(videos);
            if (id != null || id != undefined || id != '') {
                formdate.append("id", id);
                formdate.append("videos", videos);
                console.log(formdate);
                var url = "/rf/updatebr";
                $.ajax({
                    url: url,
                    type: 'POST',
                    cache: false,
                    data: formdate,
                    processData: false,
                    contentType: false
                }).done(function (data) {
                    console.log(data);
                    if (data.success) {
                        $('#RecordModel').modal('close');
                        window.location.reload();
                    } else {
                        alert(data.msg);
                    }
                }).fail(function (res) {
                    alert("网络异常");
                });
            }
        }

    </script>
</body>

</html>
